package com.lx.oms.controller.service.impl;

import java.math.BigInteger;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.entity.R;
import com.lx.oms.common.utils.CommonUtils;
import com.lx.oms.controller.entity.BroadcastEntity;
import com.lx.oms.controller.manager.BroadcastManager;
import com.lx.oms.controller.service.BroadcastService;

/**
 * 轮播图
 *
 * @author ZhouChenglin
 * @email yczclcn@163.com
 * @url www.chenlintech.com
 * @date 2018年7月06日 下午1:55:51
 */
@Service("broadcastService")
public class BroadcastServiceImpl implements BroadcastService {

	@Autowired
	private BroadcastManager broadcastManager;

	@Override
	public Page<BroadcastEntity> listBroadcast(Map<String, Object> params) {
		Query query = new Query(params);
		Page<BroadcastEntity> page = new Page<>(query);
		broadcastManager.listBroadcast(page, query);
		return page;
	}

	@Override
	public R saveBroadcast(BroadcastEntity broadcast) {
		int count = broadcastManager.saveBroadcast(broadcast);
		return CommonUtils.msg(count);
	}

	@Override
	public R getBroadcastById(BigInteger id) {
		BroadcastEntity tBroadcast = broadcastManager.getBroadcastById(id);
		return CommonUtils.msg(tBroadcast);
	}

	@Override
	public R updateBroadcast(BroadcastEntity broadcast) {
		int count = broadcastManager.updateBroadcast(broadcast);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(String[] id) {
		int count = broadcastManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
